<!--#include file="conn.asp"-->
<%
    dim rs
	dim sName,sPhone,sex,sPlace,code,describe,querycode
	showall
    function AddNewClient(name,phone,place,sex,describe,querycode)
        dim rse
        dim maxnum
        maxnum=GetMaxNumber()
        set rse=server.createobject("adodb.recordset")
        rse.open "s_request",conn,3,3
            rse.addnew
            rse("sName")=name
            rse("sPhone")=phone
            rse("sex")=sex
            rse("sPlace")=place
            rse("code")=year(now) & FixStr(month(now)) & FixStr(day(now)) & cstr(maxnum)
            rse("querycode")=querycode
			rse("describe")=describe
			rse("numtoday")=maxnum
			rse.update
        rse.close
		AddNewClient="ok"
    end function
    function GetMaxNumber()
        dim res
        set res=server.createobject("adodb.recordset")
        res.open "select iif(isnull(max(id)),0,max(id)) as MaxID from s_request",conn,3,3
            if res.recordcount=0 then
                GetMaxNumber=0
                res.close
                exit function
            end if
            GetMaxNumber=res("MaxID")
            res.close
            exit function
        res.close
    end function
	
	function showall()
        dim res
        set res=server.createobject("adodb.recordset")
        res.open "select * from s_request",conn,3,3
            if res.recordcount=0 then
                res.close
                exit function
            end if
            do while not res.eof = true
				response.write(res("sName"))
				response.write("<br />")
				res.movenext
			loop
            res.close
            exit function
        res.close
    end function
%>